package com.hyz.controller;

import com.hyz.pojo.ResponseResult;
import com.hyz.pojo.assetSecondment.AssetSecondment;
import com.hyz.pojo.assetSecondment.AssetSecondmentResult;
import com.hyz.utils.AssetSecondmentUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author HGD
 * @date 2022/10/10 0:05
 */
@Api("财务人员")
@RequestMapping("/financial")
@RestController
public class FinancialController {
    @Autowired
    private AssetSecondmentUtils asUtils;

    @ApiOperation("财务人员获取资产借调申请")
    @PostMapping("/clGetAssetSecondment")
    public ResponseResult<List<AssetSecondment>> flGetAssetSecondments() {
        return asUtils.getAssetSecondments(AssetSecondmentResult.CHARGE_LEADER_AGREE);
    }

    @ApiOperation("财务人员审批借调申请")
    @PostMapping("/clUpdateAssetSecondment")
    public ResponseResult<String> flUpdateAssetSecondment(@RequestParam("assetSecondmentId") Long assetSecondmentId,
                                                          @RequestParam("result") AssetSecondmentResult result) {
        return asUtils.updateAssetSecondment(assetSecondmentId, AssetSecondmentResult.CHARGE_LEADER_AGREE, result);
    }
}
